package breadfactory.report.dao;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;

import org.springframework.orm.ibatis.SqlMapClientTemplate;


import breadfactory.workorder.dto.WorkOrderDTO;

import breadfactory.workorder.dto.DoughLotDTO;
import breadfactory.workorder.dto.HistoryDTO;

import breadfactory.workorder.dto.WorkOrderDTO;

public class ReportDAO {
	private SqlMapClientTemplate client;
	public void setSqlMapClientTemplate(SqlMapClientTemplate client){
		this.client = client;
	}

	public ArrayList selectHistoty() throws SQLException{
		return  (ArrayList) client.queryForList("report.selectHistoty");
	}
	public WorkOrderDTO selectAllWorkOrderById(String workOrderId)throws SQLException{
		return (WorkOrderDTO) client.queryForObject("report.selectWorkOrderById", workOrderId);
	}

	public WorkOrderDTO selectWorkOrderById(String workOrderId)throws SQLException{
		return (WorkOrderDTO) client.queryForObject("report.selectWorkOrderById",workOrderId);
	}
	public ArrayList select_wip(String workOrderId)throws SQLException{
		return (ArrayList) client.queryForList("report.select_wip",workOrderId);
	}
	public ArrayList selectDateTime(String start, String end)throws SQLException{
		HashMap map = new HashMap();
	//	int sta = Integer.parseInt(start);
	//	int en = Integer.parseInt(end);
		//System.out.println(en);
		
		map.put("start", start);
		map.put("end", end);
		return (ArrayList) client.queryForList("report.selectDateTime", map);
	}


	public ArrayList getAllWorkOrderDAO() {		
		
		return (ArrayList) client.queryForList("report.getAllWorkOrder");
	}

	public DoughLotDTO selectDoughLotByIdDAO(String workOrderId) {		
		return (DoughLotDTO) client.queryForObject("report.selectDoughLotById", workOrderId);
	}

	public ArrayList selectSeperDouByDouIdDAO(String doughLotId) {		
		return (ArrayList) client.queryForList("report.selectSeperDouByDou", doughLotId);
	}
	
	public ArrayList selectHistoryFromYearByDateDAO() {
		return (ArrayList) client.queryForList("report.selectHistoryFromYearByDate");				
	}
	
	public ArrayList selectHistoryFromMonthByDateDAO() {
		return (ArrayList) client.queryForList("report.selectHistoryFromMonthByDate");				
	}
	
	public ArrayList selectHistoryFromDateByDateDAO() {
		return (ArrayList) client.queryForList("report.selectHistoryFromDateByDate");				
	}
	
	public ArrayList selectProductAVGDAO(){
		return (ArrayList) client.queryForList("report.selectProductAVG");
	}

	
	public ArrayList selectAVGHis(){
		return (ArrayList) client.queryForList("report.selectAVGHis");
	}
	
	public ArrayList selectAvgWork(){
		return (ArrayList) client.queryForList("report.selectAvgWork");
	}
	
	public ArrayList selectAVGHisMonth(){
		return (ArrayList) client.queryForList("report.selectAVGHisMonth");
	}
	
	public ArrayList selectAvgWorkMonth(){
		return (ArrayList) client.queryForList("report.selectAvgWorkMonth");
	}
	
	public ArrayList selectAVGHisDate(){
		return (ArrayList) client.queryForList("report.selectAVGHisDate");
	}
	
	public ArrayList selectAvgWorkDate(){
		return (ArrayList) client.queryForList("report.selectAvgWorkDate");
	}

}
